package com.xhs.utils;

import com.alibaba.fastjson.JSONObject;

import java.util.HashMap;

/**
 * @desc:
 * @projectName: tools-parent
 * @author: xhs
 * @date: 2022/12/4 23:32
 * @version: JDK 1.8
 */
public class JvmMapCacheUtils<V> {

    private static HashMap<String, String> cacheMap = new HashMap<String, String>();

    public static void putEntity(String key, Object object) {
        cacheMap.put(key, JSONObject.toJSONString(object));
    }

    public static <T> T getEntity(String key, Class<T> t) {
        String json = cacheMap.get(key);
        return JSONObject.parseObject(json, t);
    }
}
